﻿Namespace Functions

    Public Class MetisJoinList
        Inherits System.ComponentModel.BindingList(Of MetisJoin)

        Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As MetisJoin)
            For Each Join As MetisJoin In Me
                If (item.LeftField.Equals(Join.LeftField) And item.RightField.Equals(Join.RightField)) OrElse _
                   (item.LeftField.Equals(Join.RightField) And item.RightField.Equals(Join.LeftField)) Then

                    If item.JoinType <> Join.JoinType Then
                        SetItem(Me.IndexOf(Join), item)
                    End If
                    Exit Sub

                End If
            Next

            MyBase.InsertItem(index, item)
        End Sub

    End Class


End Namespace

